StyledTextPrinter Class
Used to print styled text stored in an EditField.
More information available in parent classes: Object
Examples
The following example prints the styled text in an EditField. The EditField's MultiLine and Styled properties must be set to True to accept and print styled text.
Dim stp as StyledTextPrinter
Dim g as Graphics
g= OpenPrinterDialog()
If g <> Nil then
stp=EditField1.StyledTextPrinter(g,72*7.5)
stp.DrawBlock 0,0,72*10
End if
Dim g as Graphics
g= OpenPrinterDialog()
If g <> Nil then
stp=EditField1.StyledTextPrinter(g,72*7.5)
stp.DrawBlock 0,0,72*10
End if
This example prints the contents of EditField1 in two columns with a quarter-inch of spacing between them. The EOF property is used to determine if all the text has been printed. When EOF is False, it prints the second column or prints another page.
Dim g as Graphics
Dim stp as StyledTextPrinter
Dim ColumnWidth, SpaceBetweenColumns, PageHeight as Integer
Dim ColumnToPrint as Integer
ColumnWidth = 261
//7.5 inches minus 1/4 inch for space
//divided by 2
SpaceBetweenColumns = 18
//18 pixels is 1/4 inch
PageHeight = 10 * 72
//10 inches * 72 pixels per inch
g= OpenPrinterDialog()
If g <> Nil then
stp=EditField1.StyledTextPrinter(g,540)
stp.width = ColumnWidth
ColumnToPrint = 1
Do until stp.eof
stp.DrawBlock (columnWidth+SpaceBetweenColumns)*
(columnToPrint-1),0,PageHeight
If ColumnToPrint = 2 then //printing last column
If Not stp.eof then // more text to print
g.nextPage
ColumnToPrint = 1
End if
Else // more columns to print on this page
ColumnToPrint = columnToPrint + 1
End if
Loop
End if
Dim stp as StyledTextPrinter
Dim ColumnWidth, SpaceBetweenColumns, PageHeight as Integer
Dim ColumnToPrint as Integer
ColumnWidth = 261
//7.5 inches minus 1/4 inch for space
//divided by 2
SpaceBetweenColumns = 18
//18 pixels is 1/4 inch
PageHeight = 10 * 72
//10 inches * 72 pixels per inch
g= OpenPrinterDialog()
If g <> Nil then
stp=EditField1.StyledTextPrinter(g,540)
stp.width = ColumnWidth
ColumnToPrint = 1
Do until stp.eof
stp.DrawBlock (columnWidth+SpaceBetweenColumns)*
(columnToPrint-1),0,PageHeight
If ColumnToPrint = 2 then //printing last column
If Not stp.eof then // more text to print
g.nextPage
ColumnToPrint = 1
End if
Else // more columns to print on this page
ColumnToPrint = columnToPrint + 1
End if
Loop
End if
See Also
EditField control; OpenPrinter, OpenPrinterDialog functions; Graphics, PrinterSetup classes.